/*
 * Copyright 2005-2013 the original author or authors.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 * 
 * Project website:
 *      http://www.cottsoft.com
 */
package com.cottsoft.framework.common.util;

import java.lang.reflect.Constructor;

/**
 * Class Description: <br> 
 * 对象工具类，如:通过反射得到对象实例
 * @author  Simon.Hoo(simon@cottsoft.com)
 * @date    2010年8月2日
 * @version v1.0
 * @since   1.0
 */
public class ObjectUtils {
	
	/**
	 * Description: <br>
	 * 通过JDK反射得到对象实例。
	 * @param className 类名(如：com.util.ObjectUtil)
	 * @param parameterTypes 构造参数类型数组列表
	 * @param param 构造参数值数组列表
	 * @return 对象实例
	 */
	public static Object newInstance(String className, Class<?>[] parameterTypes, Object[] param){
		Class<?> clazz=null;
		Constructor<?> constructor = null;
		Object obj = null;
		try{
			clazz = Class.forName(className);
			constructor = clazz.getConstructor(parameterTypes);
			obj = (Object) constructor.newInstance(param);
		}catch(ClassNotFoundException e){
			e.printStackTrace();
		} catch (Exception e) {
			e.printStackTrace();
		}	
		return obj;
	}
}


